package ipad.asia.controller;

import com.alibaba.fastjson.JSON;
import ipad.asia.entity.PunishConsumer;
import ipad.asia.entity.PunishEnterprise;
import ipad.asia.service.admin.AdminFeign;
import ipad.asia.service.punish.PunishConsumerFeign;
import ipad.asia.service.punish.PunishEnterpriseFeign;
import ipad.asia.service.shop.ShopFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ReportController {
    @Autowired
    private PunishEnterpriseFeign punishEnterpriseFeign;
    @Autowired
    private PunishConsumerFeign punishConsumerFeign;
    @RequestMapping("/report/shopList")
    public String shopList(Model model){
        List<PunishEnterprise> reports = punishEnterpriseFeign.findAll();
        model.addAttribute("reports",reports);
        return "shopReport";
    }

    @RequestMapping("/report/shopDetail")
    public String shopDetail(@RequestParam(value = "id",required = false)int id,
                             Model model){
        PunishEnterprise punishEnterprise = punishEnterpriseFeign.findById(id);
        model.addAttribute("report",punishEnterprise);
        return "shopDetail";
    }



    @RequestMapping("/report/ConsumerList")
    public String consumerDetail(Model model){
        List<PunishConsumer> reports = punishConsumerFeign.findAll();
        model.addAttribute("reports",reports);
        return "consumerReport";
    }

    @RequestMapping("/report/ConsumerDetail")
    public String ConsumerList(@RequestParam(value = "id",required = false)int id,
                               Model model){
        PunishConsumer punishConsumer = punishConsumerFeign.findById(id);
        model.addAttribute("report",punishConsumer);
        return "consumerDetail";
    }
}
